package com.bluebench.bigul.service.resolver;

import com.bluebench.bigul.domain.Element;
import com.bluebench.bigul.exception.GraphicInitializationException;

public class AttributeResolver extends DefaultExpressionResolver{
	
	public AttributeResolver() throws GraphicInitializationException {
		if(!IS_INITIALIZED){
			super.resolve();
		}
	}
	
	@Override
	public void resolve() throws GraphicInitializationException {
		
		String expression = tag.getExpression();
		Element.Attribute attribute = (Element.Attribute)tag;
		System.out.println("A--->"+attribute.getId());		
		
		for(Element.Parameter p : attribute.getParameters()){
			p.setResolver(getInstance(PARAMETER_RESOLVER));
			p.resolve();
		}
		
		//TODO : Iterate for Chained Attributes and Resolve them
		for(Element.Attribute a : attribute.getAttributes()){
			a.setResolver(getInstance(ATTRIBUTE_RESOLVER));
			a.resolve();
		}
		
		
		if(expression!=null && validate(expression)){
			resolveExpression(expression);
		}
		
		
	}

	

}
